package com.biostime.qdingding.modules.cms.service;

import java.util.HashMap;
import java.util.List;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.biostime.qdingding.common.persistence.Page;
import com.biostime.qdingding.common.service.CrudService;
import com.biostime.qdingding.modules.cms.dao.ArticleDao;
import com.biostime.qdingding.modules.cms.entity.Article;
import com.biostime.qdingding.modules.qd.api.dto.ArticleDto;

/**
 * 文章表Service
 * @author king
 * @version 2015-12-11
 */
@Service
@Transactional(readOnly = true)
public class ArticleService extends CrudService<ArticleDao, Article> {
	
	@Override
	public List<Article> findList(Article entity) {
		if(entity == null ){
			entity = new Article();
		}
		dataScopeFilter(entity, "dsf", "id=a.center_id", "id=a.create_by");
		return super.findList(entity);
	}
	
	@Override
	public Page<Article> findPage(Page<Article> page, Article entity) {
		entity.setPage(page);
		page.setList(this.findList(entity));
		return page;
	}
	
	
//	<!-- ————————————————————————————楚河汉界，谁敢动我的，打死 ————————————————————————————————————-->
	public List<HashMap<String,Object>>  getArticleCategory(String centerId){
		return dao.getArticleCategory(centerId);
	}
	
	public List<ArticleDto> getArticles(String categoryId,String channelId){
		return dao.getArticles(categoryId, channelId);
	}
	
	public List<ArticleDto> getRecommendArticle(String categoryId,String channelId){
		return dao.getRecommendArticle(categoryId, channelId);
	}	
	
	public ArticleDto getArticleById(String id){
		return dao.getArticleById(id);
	}	
	
	public ArticleDto getArticleByTitle(String title){
		return dao.getArticleByTitle(title);
	}
}
